home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 06 - 1990 / 06.07 Jul 90 / Printing Primer ƒ / BeginReport.c next >
Encoding:
C/C++ Source or Header  |  1989-11-07  |  2.9 KB  |  111 lines  |  [TEXT/KAHL]

  1. /*******************************************\
  2. *    file:         BeginReport.c                *
  3. *    version:    0.1ß                        *
  4. *     XCMD ID        500                            *
  5. *                                            *
  6. * Opens access to the printer for the         *
  7. * current report.                            *
  8. *                                            *
  9. * Returns True if the user clicks ok in the    *
  10. * job dialog, false otherwise.                *
  11. * -----------------------------------------    *
  12. * By:    Donald Koscheka                        *
  13. * Date:    30-OCT-89                            *
  14. * ©    Copyright 1989, Donald Koscheka            *
  15. *    All Rights Reserved                        *
  16. *                                            *
  17. * -----------------------------------------    *
  18. \*******************************************/
  19.  
  20. #include <MacTypes.h>
  21. #include <MemoryMgr.h>
  22. #include <ResourceMgr.h>
  23. #include <OSUtil.h>
  24. #include <HyperXCmd.h>
  25. #include <HyperUtils.h>
  26. #include <PrintMgr.h>
  27. #include "ReportUtils.h"
  28.  
  29.     
  30.  
  31.  
  32. pascal void main( paramPtr )
  33.     XCmdBlockPtr    paramPtr;
  34. /**********************************
  35. * we allocate the page information 
  36. * record as a resource so that 
  37. * subsequent xcmds will be able to
  38. * find the data using getresource()
  39. *
  40. *
  41. * allocate the resource in the system
  42. * resource fork.
  43. **********************************/
  44. {
  45.     Handle        pH;
  46.     pInfoPtr    pp;
  47.     TPPrPort    tp;
  48.     short        oldRes;
  49.     THPrint        printRec;
  50.     Handle        result;
  51.     
  52.     if( !(pH = GetSystemResource( PAGE_INFO, PAGE_ID )) ){
  53.         if( pH = NewSysHandle( (long)sizeof( pInfo ) ) ){
  54.             PrOpen();
  55.             
  56.             if( printRec = (THPrint)NewHandle( (long)sizeof(TPrint) ) ){
  57.                 PrintDefault( printRec );
  58.                 
  59.                 if( PrJobDialog( printRec ) ){
  60.                 
  61.                     AddSystemResource( pH, (ResType)PAGE_INFO, PAGE_ID,
  62.                                         "\p page information record" );
  63.                     
  64.                     pp = (pInfoPtr)*pH;
  65.                     pp->prRecHandle = printRec;
  66.  
  67.                     tp = PrOpenDoc( pp->prRecHandle, NIL, NIL );
  68.  
  69.                     pp->prPort = (GrafPtr)tp;
  70.                     PrOpenPage( tp, NIL );
  71.                     
  72.                     pp->curntPen.v = pp->curntPen.h = 0;
  73.                     
  74.                     pp->pagecount = 1;    /*** for printing on bottom of page ***/
  75.                     pp->totalpages = 0; /*** for resetting the document.    ***/
  76.                     pp->footNote.key1    = NIL;
  77.                     pp->footNote.key2    = NIL;
  78.                     pp->footNote.key3    = NIL;
  79.                     pp->footNote.hite    = 0;
  80.                         
  81.                     SetMargin( pp, 0, 0, 0, 0 );
  82.                     
  83.                     SetFont( (stylePtr)&(pp->curntStyle), DEFAULT_FONT );
  84.                     SetFontSize( (stylePtr)&(pp->curntStyle), DEFAULT_SIZE );
  85.                     SetFontStyle( (stylePtr)&(pp->curntStyle), PLAIN_TEXT );
  86.                     SetFontJust( (stylePtr)&(pp->curntStyle), teJustLeft );
  87.                                     
  88.                     SetFont( (stylePtr)&(pp->defaultStyle), DEFAULT_FONT );
  89.                     SetFontSize( (stylePtr)&(pp->defaultStyle), DEFAULT_SIZE );
  90.                     SetFontStyle( (stylePtr)&(pp->defaultStyle), PLAIN_TEXT );
  91.                     SetFontJust( (stylePtr)&(pp->defaultStyle), teJustLeft );
  92.                     
  93.                     result = PasToZero( paramPtr, "\pTRUE");
  94.                 }/* if job dialog */
  95.                 else{
  96.                     TrashHandle( (Handle)printRec );
  97.                     TrashHandle( (Handle)pH );
  98.                     result = PasToZero( paramPtr, "\pFALSE");
  99.                 }/* else         */
  100.             }/* if printRec    */
  101.         }/* if pH allocated */
  102.     }/* if pH not previously allocated */
  103.     
  104.     paramPtr->returnValue = result;
  105.  
  106. }
  107.  
  108.  
  109.  
  110.  
  111.